define(function(require, exports, module){
	require("resource/js/easyui/themes/icon.css");
	require("resource/js/easyui/easyloader.js");
	require("resource/font-awesome-4.7.0/css/font-awesome.min.css");
	require('resource/font-awesome-4.7.0/css/icomoon.css');
	var ajax = require("resource/js/component/ajax.js");
	var parentDlgObj;
	var initThisPage = function(dlg){
		indexApp.setUserIds = [];
		parentDlgObj = dlg;
		$("#nodeNum").val(dlg.dialog("options").params.nodeNum);
		$("#processKey").val(dlg.dialog("options").params.processKey);
		$("#branchValId").val(dlg.dialog("options").params.branchValId);
		$("#isDefined").val(dlg.dialog("options").params.is_defined);
		initNoConditionUser();
		$("#setNoCondition").unbind('click');
		$("#setNoCondition").bind('click',function(){
			setProcessPerson($("#processKey").val(),$("#nodeNum").val());
		});
		$("#setCondition").unbind('click');
		$("#setCondition").bind('click',function(){
			setProcessCondition(BASEPATH+"/view/oa/act/approval/progress/select");
		});
		initConditionUsers();
		
		$("#goBackBtn").linkbutton({
			iconCls: 'icon-goback',
			iconAlign:"left",
			onClick:function(){
				parentDlgObj.dialog("close");
			}
		}).addClass("linkBtn");
		
		var height = $(window).height()-$(".backhead").height()-$(".approval-condition").height()-$(".approval-condition-head").height()-50;
		$("#conditionsdiv").css({
			"height":height,
			"overflow-y": "auto"
		});
	};
	var initNoConditionUser = function(){
		ajax.init().success(function(code,msg,data){
			if(data!=undefined||data!=null){
				var context = "<ul id=\"setUserParent\">";
				var status = 0;
				$.each(data,function(i,val){
					if(val.status=="1"){
						status = 1;
					}
					if(i!=0){
						context+='<li><span class="OAimgArrow"><img src="'+BASEPATH+'/act/images/arrow-right-oa.png" /></span></li>';
					}
					var url="/resource/images/user_icon.png";
					if(val.imgurl!=undefined&&val.imgurl!=""){
						url=val.imgurl;
					}
					context+='<li><span class="OAimgICON"><img src="'+BASEPATH+url+'" /></span><span>'+val.username+'</span></li>';
				});
				context += "</ul>";
				$("#setNoConditionDiv").html(context);
				if(status==0){
					$("#bftj_status").text('已启用');
					$("#updateNoCoditionStatus").text('停用');
					$("#updateNoCoditionStatus").attr("status",1);
				}else{
					$("#bftj_status").text('未启用');
					$("#updateNoCoditionStatus").text('启用');
					$("#updateNoCoditionStatus").attr("status",0);
				}
				$("#updateNoCoditionStatus").unbind('click');
				$("#updateNoCoditionStatus").bind('click',function(){
					updateNoConditionStatus(this);
				});
			}else{
				$("#updateNoCoditionStatus").parent().remove();
				$("#bftj_status").text('未设置');
			}
			
		}).post(BASEPATH+"/oa/act/actExUserDef/getUserImgs.htm",{processKey:$("#processKey").val(),isDefined:$("#isDefined").val()});
	};
	var updateNoConditionStatus=function(obj){
		ajax.init().success(function(code,msg,data){
			initNoConditionUser();
		}).post(BASEPATH+"/oa/act/actExUserDef/startSet.htm",{checkeds:$("#processKey").val(),status:$(obj).attr("status")});
	};
	var setProcessPerson = function(processKey,nodeNum){
		$(".setProcessPersonDlg").remove();
		setProcessPerson.dlg = $("<div class='setProcessPersonDlg'><div>").appendTo($("body")).dialog({
			title:"审核人设置",
			width:800,
			height:600,
			closed: false,    
		    cache: true,    
		    modal: true,
			href:BASEPATH+"/view/oa/act/approval/progress/set",
			onLoad:function(){
				$("#setUser").html("");
				$("#nodeNum").val(nodeNum);
				$("#processKey").val(processKey);
				initConditionUsers();
				indexApp.setUserIds = [];
				seajs.use("oa/act/approval/progress/js/set", function(set) {
					set.init();
				});
			},
			buttons:[{
				text:'重置',
				iconCls:'icon-reload',
				accessKey:{akey:18,mkey:83},
				handler:function(){
					indexApp.setUserIds=[];
				    $("#setUser").html("");
				}},{
				text:'保存',
				iconCls:'icon-ok',
				accessKey:{akey:18,mkey:83},
				handler:function(){
					using(["form"],function(){
						if(indexApp.setUserIds == undefined || indexApp.setUserIds == null || indexApp.setUserIds.length==0){
							$.messager.alert("系统提示","请设置流程处理人");
						}else{
							ajax.init().success(function(code,msg,data){
								$("#setNoConditionDiv").html($("#setUser").html());
								setProcessPerson.dlg.dialog("close");
								$.messager.show({
					    			title:'系统提示',
					    			msg:msg,
					    			timeout:5000,
					    			showType:'slide'
					    		});
								initNoConditionUser();
								initConditionUsers();
							}).error(function(code,msg,data){
								$.messager.alert("系统提示",msg);
							}).post(BASEPATH+"/oa/act/actExUserDef/setDealUsers.htm",{setUserIds:JSON.stringify(indexApp.setUserIds),processKey:processKey,isDefined:$("#isDefined").val()});
						}
						
					});
				}
				},{
				text:'关闭',
				addClass:'l-btn-red',
				iconCls:'icon-not',
				id:"del",
				accessKey:{akey:18,mkey:67},
				handler:function(){
					setProcessPerson.dlg.dialog('close');
				}
			}]
		});
	};
	var setProcessCondition=function(baseUrl){
		var branchValId = $("#branchValId").val();
		if(branchValId!=undefined&&branchValId!=null&&branchValId!=''&&branchValId!='undefined'){
			$.messager.show({
				title:'系统提示',
				msg:'条件已选择，如需修改，请点击【删除】按钮，删除当前配置.',
				timeout:5000,
				showType:'slide'
			});
			return;
		}else{
			$("#formdlg").dialog({
				iconCls:'icon-save',
				title:'分条件审批设置',
				href:baseUrl,
				onLoad:function(){
					$("#conditionForm").show();
					$(".approvaloption").hide();
					$("#conditionForm .tabseach").html('');
					$("#setSub").linkbutton('enable');
					$("#nodeNumes").val($("#nodeNum").val());
					using(["form"],function(){
						ajax.init().success(function(code,msg,data){
							$('#conditionForm>div').html('');
							if(data.item&&data.item.length>0){	
								for(var it in data.item){
									if(data.item[it].showtype&&data.item[it].showtype=='select'){
										var selectArr = data.detail[data.item[it].colkey];
										var htm = $("<div></div>");
										for(var m in selectArr){
											htm.append("<span>"+selectArr[m].text+"</span>");
										}
										$('#conditionForm>div').append(
												'<div style="border-bottom: 1px solid #ddd;padding: 5 0 10 20;">'+												
												'<div class="seTitle">'+
												    '<input type="hidden" name="dataonchange" value="'+data.item[it].dataonchange+'"/>'+
												    '<input type="hidden" name="para" value=\''+JSON.stringify(selectArr)+'\'/>'+
													'<input style="max-width:16px;position: relative;top: 6px;margin: 0;" type="radio" name="radio" class="seInput" value="'+data.item[it].colkey+'"  col="'+data.item[it].colname+'">'+
													'<label><span style="padding: 0px 5px;color: red;">*</span>'+data.item[it].colnamech+'</label>'+
												'</div>'+
												'<div class="" style="clear:both;padding-left: 22px;">'+
													'<div style="color: #999;padding:5px 0px 12px 0px;"><span>选项内容将会作为审批条件</span></div>'+
													'<div class="listTypebackground">'+htm.html()+'</div>'+
												'</div>'+
											'</div>'+
										'</div>');
												

									}else if((data.item[it].showtype&&data.item[it].showtype=='number')  || (data.item[it].showtype&&data.item[it].showtype=='integer')){
										$('#conditionForm>div').append(
												'<div style="border-bottom: 1px solid #ddd;padding: 5 0 10 20;">'+
												'<div class="seTitle">'+
													'<input style="max-width:16px;position: relative;top: 6px;margin: 0;" type="radio" name="radio" class="seInput" value="'+data.item[it].colkey+'"  col="'+data.item[it].colname+'">'+
													'<label><span style="padding: 0px 5px;color: red;">*</span>'+data.item[it].colnamech+'</label>'+
												'</div>'+
												'<div class="" style="clear:both;padding-left:22px;">'+
													'<div style="color:#999;padding-top:5px;"><span>请输入'+data.item[it].colnamech+'的分隔数字</span></div>'+
													'<div><span class="listlast"><input class="easyui-numberbox" value="0" type="text" data-options="required:true,precision:1" /></span><span class="listlast"><span style="padding:0px 5px; position: relative; top:5px;">≤</span><input value="3" class="easyui-numberbox" type="text" data-options="required:true,precision:1" /></span>'+
													'<img style="position: relative;top: 12px; padding:0px 10px;width:20px;height:20px;" name="adimg" src="'+BASEPATH+'/resource/js/easyui/themes/icons/edit_add.png"/>'+
													'<img name="delimg" src="'+BASEPATH+'/resource/js/easyui/themes/icons/edit_remove.png" style="display:none;position: relative;top: 12px;width:20px;height:20px;" num="2"/>'+
													'</div>'+
												'</div>'+
											'</div>'+
										'</div>');
									}
								}
							}else{
								$('#conditionForm>div').html("<div><span style='padding:0px 25px;line-height: 30px;'>没有可以设置的审批条件</span></div>");
								$("#setSub").linkbutton('disable');
							}
							
							$.parser.parse('#conditionForm>div');
						    $("img[name='adimg']").click(function(){
						    	var num = parseInt($(this).next().attr("num"));
						    	var httext =$("<span class='listlast' name='listlast"+num+"'></span>");
						    	var tex =$('<input type="text" class="easyui-numberbox" data-options="required:true,precision:1" />');	
						    	  httext.append(tex);
						         $(this).before(httext);
								 tex.numberbox({}).after("<span style='padding:0px 5px;position: relative; top:5px;'>≤</span>");
								 $(this).next().css("display","inline-block");
								
								$(this).next().attr("num",(num+1));
						   });
						   $("img[name='delimg']").click(function(){
							   var num = parseInt($(this).attr("num")) ;
							   num = num -1 ;
							   $(this).parent().find("span[name=listlast"+num+"]").remove();
							   $(this).before().before();
							   $(this).attr("num",num);
							   if(num<=2){
								   $(this).css("display","none");
							   }
						   });
							
						}).error(function(code,msg,data){
							$.messager.alert('系统提示',msg);
						}).post(BASEPATH+"/oa/act/actExProcessBranch/getSelectPage.htm",{processKey:$("#processKey").val(),isDefined:$("#isDefined").val()});
					});
				},
				buttons:[                {
					text:'确定',
					iconCls:'icon-ok',
					id:'setSub',
					accessKey:{akey:18,mkey:83},
					handler:function(){
						if($("input[name=radio]:checked").length>0){		
							var numboxArr = $("input[name=radio]:checked").parent().parent().find("input[class^='easyui-']");
							var arr = [];
							var obj={};
							if(numboxArr.length>0){
								for( var m=0;m<numboxArr.length; m++){
									arr.push($(numboxArr[m]).numberbox("getValue"));
									if(!$(numboxArr[m]).numberbox("isValid")){
										$.messager.alert('系统提示',"请填写相关数据");
										return;
									}
								}
								var array2 = arr.concat();
								array2.sort(function(a,b){
									return a-b;
								});
								for(var i=0;i<arr.length;i++){
									if(arr[i]!=array2[i]){
										$.messager.alert('系统提示',"数据填写有误");
										return;
									}
								}
								
								obj.list=arr.join(',');
								obj.colkey=$("input[name=radio]:checked").val();
								obj.process_key=$("#processKey").val();
							}else{
								obj.dataonchange= $('input:radio:checked').siblings("input[name='para']").val();
								obj.process_key=$("#processKey").val();
								obj.colkey=$("input[name=radio]:checked").val();
							}
							$("#branchValId").val($("input[name=radio]:checked").attr("col"));
							obj.isDefined =$("#isDefined").val();
							ajax.init().success(function(code,msg,data){
								initConditionUsers();
								parentDlgObj.dialog("options").initProgressPage();
								$("#formdlg").dialog("close");
							}).error(function(code,msg,data){
								$.messager.alert('系统提示',msg);
							}).post(BASEPATH+"/oa/act/actExProcessBranch/saveSubProcessSet.htm",obj);
							
					   }
				 }
				},{
						text:'取消',
						addClass:'l-btn-red',
						accessKey:{akey:18,mkey:67},
						handler:function(){
							$("#formdlg").dialog("close");
						}
					}]
				});
//			$("#formdlg").dialog("open");
			$('#formdlg').window('open').window('resize',{top: '110px'});
			$("#conditionForm").show();$(".approvaloption").hide();
		}
	};
	var initConditionUsers = function(){
		var branchValId = $("#branchValId").val();
		
		if(branchValId!=undefined&&branchValId!=null&&branchValId!=''&&branchValId!="undefined"){
			ajax.init().success(function(code,msg,data){
				var is_set = 0;
				var status = 0;
				if(data.length &&data.length>0){
					$(".approvaloption").html("");
					var html2="";
					for(var i=0;i<data.length;i++){
						if(data[i].set_status == '1'){
							is_set = 1;
						}
						if(data[i].status=='1'){
							status = 1;
						}
						var html = "";
						var storeIds=[];
						if(data[i].users.length>0){
							for(var j=0;j<data[i].users.length;j++){
								var userinfo = {userid:data[i].users[j].user_id,usertype:data[i].users[j].user_type};
								storeIds.push(userinfo);
								if(j!=0){
									html+='<li><span class="OAimgArrow"><img src="'+BASEPATH+'/act/images/arrow-right-oa.png" /></span></li>';
								}
								var url="/resource/images/user_icon.png";
								if(data[i].users[j].user_img!=undefined&&data[i].users[j].user_img!=""){
									url=data[i].users[j].user_img;
								}
								html+='<li><span class="OAimgICON"><img src="'+BASEPATH+url+'" /></span><span>'+data[i].users[j].user_name+'</span></li>';
							}
						}
						html2 += "<div class='approval-option'>" +
								"<div class='approval-option-head'>" +
								"<span>当“"+data[i].branch_expdesc+"”时</span><span class='setConditionUserBtn' processKey='"+$("#processKey").val()+"' nodeNum='"+$("#nodeNum").val()+"' branch_id='"+data[i].branch_id+"' index='"+i+"' userinfo='"+JSON.stringify(storeIds)+"'><a href='javascript:void(0)'>设置审批人</a></span></div>"+
								"<div class='approval-option-body'><div class='setUserOa' id='setUserOa"+i+"'>"+html+"</div>"+
								"</div>";
					}
					$(".approvaloption").html(html2);
					$(".setConditionUserBtn").click(function(){
						updDialogInit(BASEPATH+"/view/oa/act/approval/progress/set",this);
					});
					$(".approvaloption").show();
					if(is_set == 1){
						$("#ftj").text("审核人未设置正确");
						$("#updateConditionStatus").parent().hide();
						$("#setCondition").parent().hide();
						$("#deleteCondition").parent().show();$("#deleteCondition").css('right','10px');
					}else{
						if(status==1){
							$("#ftj").text("未启用");
							$("#updateConditionStatus").text("启用");
							$("#updateConditionStatus").attr("status",0);
							$("#updateConditionStatus").parent().show();
							$("#setCondition").parent().hide();
							$("#deleteCondition").parent().show();
						}else{
							$("#ftj").text("已启用");
							$("#updateConditionStatus").parent().show();
							$("#updateConditionStatus").text("停用");
							$("#updateConditionStatus").attr("status",1);
							$("#setCondition").parent().hide();
							$("#deleteCondition").parent().show();
						}
					}
					$("#deleteCondition").unbind('click');
					
					$("#deleteCondition").bind('click',function(){
						updateConditionStatus(this,'删除');
					});
					$("#updateConditionStatus").unbind('click');
					$("#updateConditionStatus").bind('click',function(){
						updateConditionStatus(this,'设置');
					});
				}
			}).error(function(code,msg,data){
				$.messager.alert('系统提示',msg);
			}).post(BASEPATH+"/oa/act/actExProcessBranch/querySubSet.htm",{branchValId:$("#branchValId").val(),isDefined:$("#isDefined").val(),processKey:$("#processKey").val()});
		}else{
			$("#ftj").text("未设置");
			$("#updateConditionStatus").parent().hide();
			$("#deleteCondition").parent().hide();
			$("#setCondition").parent().show();
		}
	};
	var updateConditionStatus = function(obj,msghead){
		
		ajax.init().success(function(code,msg,data){
			if(msghead=="删除"){
				$.messager.confirm("系统提示","是否要删除分条件审批？",function(r){
					if(r){
						$.messager.show({ title:'系统提示', msg:msghead+'成功', timeout:5000, showType:'slide' });
						$("#branchValId").val("");
						$(".approvaloption").html("");
						initConditionUsers();
						parentDlgObj.dialog("options").initProgressPage();
					}
				});
			}else{
				$.messager.show({
					title:'系统提示',
					msg:msghead+'成功',
					timeout:2000,
					showType:'slide'
				});
				initConditionUsers();
				parentDlgObj.dialog("options").initProgressPage();
			}
		}).post(BASEPATH+"/oa/act/actExProcessBranch/updateSet.htm?status="+$(obj).attr("status"),{checkeds:$("#processKey").val(),isDefined:$("#isDefined").val()});
	};
	//修改
	var updDialogInit=function(baseUrl,obj){
		var index = $(obj).attr("index");
		$(obj).addClass("checked");
		$("#formdlg").dialog({
			top:110,
			iconCls:'icon-save',
			title:'设置',
			href:baseUrl,
			onLoad:function(){
				$("#setUser").text("");
				indexApp.setUserIds = [];
				function btnClickBind(){
					$("#userBtn").bind("click",function(){
						$("#userDiv").show();$("#deptDiv").hide();$("#roleDiv").hide();
						$("#userBtn").attr("class","button select");
						$("#deptBtn").attr("class","button");
						$("#roleBtn").attr("class","button");
					});
					$("#deptBtn").bind("click",function(){
						$("#userDiv").hide();$("#deptDiv").show();$("#roleDiv").hide();
						$("#userBtn").attr("class","button");
						$("#deptBtn").attr("class","button select");
						$("#roleBtn").attr("class","button");

					});
					$("#roleBtn").bind("click",function(){
						$("#userDiv").hide();$("#deptDiv").hide();$("#roleDiv").show();
						$("#userBtn").attr("class","button");
						$("#deptBtn").attr("class","button");
						$("#roleBtn").attr("class","button select");

					});
					$("#directorBtn").bind("click",function(){
						var setUser=$("#setUser").html();
						var nodeNum=$("#nodeNum").val();
						if(indexApp.setUserIds!=null&&indexApp.setUserIds.length>0){
							if(indexApp.setUserIds.length>=nodeNum){
								$.messager.alert("系统提示","无法添加处理人，该流程只能设置"+nodeNum+"步处理人！");
								return ;
							}
							setUser=setUser+'<li><span class="OAimgArrow"><img src="'+BASEPATH+'/act/images/arrow-right-oa.png" /></span></li>';
						}
						var userinfo = {userid:'director',usertype:"director"};
						indexApp.setUserIds.push(userinfo);
						var url="/resource/images/user_icon.png";
						$("#setUser").html(setUser+'<li><span class="OAimgICON"><img src="'+BASEPATH+url+'" /></span><span>主管人员</span></li>');
					});
					
				}
				require("resource/js/component/tree.js");
				using("ztree",function(){
					var setting={
						data: { 
							simpleData: {
								enable: true,
								idKey:'id',
								pIdKey:'pid'
							} 
						},
						callback: {
							onClick:onClick
						}
					};
					ajax.init().success(function(code,msg,zTreeNodes){
						for(var i=0;i<zTreeNodes.length;i++){
							if(zTreeNodes[i].type=="DEPT"){
								zTreeNodes[i].open=true;
								zTreeNodes[i].iconSkin="diy01";
							}else{
								zTreeNodes[i].iconSkin="diy02";
							}
						}
						$.fn.zTree.init($("#userTree"), setting, zTreeNodes);
					}).error(function(code,msg,data){
						$.messager.alert("系统提示",msg);
					}).post(BASEPATH+"/base/authoriza/user/getUserListByDeptId.htm");

					var deptsetting={
							data: { 
								simpleData: {
									enable: true,
									idKey:'id',
									pIdKey:'pId'
								} 
						},
						callback: {
							onClick:onClickDept
						}
					};
					ajax.init().success(function(code,msg,zTreeNodes){
						for(var i=0;i<zTreeNodes.length;i++){
							zTreeNodes[i].open=true;
							if(zTreeNodes[i].pId){
								zTreeNodes[i].iconSkin="diy03";
							}else{
								zTreeNodes[i].iconSkin="diy01";
							}
						}
						$.fn.zTree.init($("#deptTree"), deptsetting, zTreeNodes);
					}).error(function(code,msg,data){
						$.messager.alert("系统提示",msg);
					}).post(BASEPATH+"/base/authoriza/dept/queryDeptTreeByRootDept.htm");

					var rolesetting={
							data: { 
								simpleData: {
									enable: true,
									idKey:'roleId',
									pIdKey:'pId'
								} 
						},
						callback: {
							onClick:onClickRole
						}
					};
					ajax.init().success(function(code,msg,zTreeNodes){
						for(var i=0;i<zTreeNodes.length;i++){
							zTreeNodes[i].open=true;
							zTreeNodes[i].iconSkin="diy01";
							zTreeNodes[i].id = zTreeNodes[i].roleId;
							zTreeNodes[i].name = zTreeNodes[i].roleName;
						}
						$.fn.zTree.init($("#roleTree"), rolesetting, zTreeNodes);
					}).error(function(code,msg,data){
						$.messager.alert("系统提示",msg);
					}).post(BASEPATH+"/oa/oarole/queryOARole.htm");

				});
				function onClick(event, treeId, treeNode){
					if(treeNode.type=='USER'){
						var setUser=$("#setUser").html();
						var nodeNum=$("#nodeNum").val();
						if(indexApp.setUserIds!=null&&indexApp.setUserIds.length>0){
							if(indexApp.setUserIds.length>=nodeNum){
								$.messager.alert("系统提示","无法添加处理人，该流程只能设置"+nodeNum+"步处理人！");
								return ;
							}
							setUser=setUser+'<li><span class="OAimgArrow"><img src="'+BASEPATH+'/act/images/arrow-right-oa.png" /></span></li>';
						}
						var userinfo = {userid:treeNode.id,usertype:"userid"};
						indexApp.setUserIds.push(userinfo);
						var url="/resource/images/user_icon.png";
						if(treeNode.imgurl!=undefined&&treeNode.imgurl!=""){
							url=treeNode.imgurl;
						}
						$("#setUser").html(setUser+'<li><span class="OAimgICON"><img src="'+BASEPATH+url+'" /></span><span>'+treeNode.name+'</span></li>');
					}
				}

				function onClickDept(event, treeId, treeNode){
					var setUser=$("#setUser").html();
					var nodeNum=$("#nodeNum").val();
					if(indexApp.setUserIds!=null&&indexApp.setUserIds.length>0){
						if(indexApp.setUserIds.length>=nodeNum){
							$.messager.alert("系统提示","无法添加处理人，该流程只能设置"+nodeNum+"步处理人！");
							return ;
						}
						setUser=setUser+'<li><span class="OAimgArrow"><img src="'+BASEPATH+'/act/images/arrow-right-oa.png" /></span></li>';
					}
					var userinfo = {userid:treeNode.id,usertype:"deptid"};
					indexApp.setUserIds.push(userinfo);
					var url="/resource/images/sy_default.png";
					$("#setUser").html(setUser+'<li><span class="OAimgICON"><img src="'+BASEPATH+url+'" /></span><span>'+treeNode.name+'</span></li>');
				}

				function onClickRole(event, treeId, treeNode){
					var setUser=$("#setUser").html();
					var nodeNum=$("#nodeNum").val();
					if(indexApp.setUserIds!=null&&indexApp.setUserIds.length>0){
						if(indexApp.setUserIds.length>=nodeNum){
							$.messager.alert("系统提示","无法添加处理人，该流程只能设置"+nodeNum+"步处理人！");
							return ;
						}
						setUser=setUser+'<li><span class="OAimgArrow"><img src="'+BASEPATH+'/act/images/arrow-right-oa.png" /></span></li>';
					}
					var userinfo = {userid:treeNode.id,usertype:"roleid"};
					indexApp.setUserIds.push(userinfo);
					var url="/resource/images/sy_default.png";
					$("#setUser").html(setUser+'<li><span class="OAimgICON"><img src="'+BASEPATH+url+'" /></span><span>'+treeNode.name+'</span></li>');
				}

				btnClickBind();
				$("#setUser").html($("#setUserOa"+index).html());
				indexApp.setUserIds = JSON.parse($(obj).attr("userinfo"));
			},
			buttons:[{
				text:'重置',
				iconCls:'icon-reload',
				accessKey:{akey:18,mkey:83},
				handler:function(){
					indexApp.setUserIds = [];
				    setUser=$("#setUser").html("");
				}},{
				text:'保存',
				iconCls:'icon-ok',
				accessKey:{akey:18,mkey:83},
				handler:function(){
					using(["form"],function(){
							ajax.init().success(function(code,msg,data){
								var setUser=$("#setUser").html();
								$("#setUserOa"+index).html(setUser);
								$("#formdlg").dialog("close");
								initConditionUsers();
								$.messager.show({
									title:'系统提示',
									msg:'保存成功',
									timeout:5000,
									showType:'slide'
								});
							}).error(function(code,msg,data){
								$.messager.alert('系统提示',msg);
							}).post(BASEPATH+"/oa/act/actExProcessBranch/setDealUsers.htm",{setUserIds:JSON.stringify(indexApp.setUserIds),processKey:$(obj).attr('branch_id'),isDefined:$("#isDefined").val()});						
					});
				}
				},{
					text:'取消',
					addClass:'l-btn-red',
					accessKey:{akey:18,mkey:67},
					handler:function(){
						$("#formdlg").dialog("close");
					}
				}]
			});
		$('#formdlg').window('open').window('resize',{top: '110px'});
	}	
	module.exports={
		init:function(dlg){
			using(["datagrid","droppable","draggable"],function(){
				initThisPage(dlg);
			});
		}
	}
});
